﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PlanoAula.Core.Helper;
using System.IO;
using System.Data.Entity;

namespace PlanoAula
{
    public partial class Main : Form
    {
        public Main()
        {
            //CfTest.Program.Main(null);
            InitializeComponent();
        }

        private void planoDeAulaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // new ListPlanoAulaForm().ExbirFormulario(this);

        }

        private void diasNaoUteisToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new ListDiaNaoUtilForm().ExbirFormulario(this);

        }

        private void Main_Load(object sender, EventArgs e)
        {
            CriarBancoDados();
            diasNaoUteisToolStripMenuItem_Click(sender, e);
        }

        private static void CriarBancoDados()
        {
            string file = @"c:\temp\Students.sdf";
            if (!File.Exists(file) || MessageBox.Show("Deseja recriar o banco?", "Pergunta", MessageBoxButtons.YesNo) == DialogResult.OK)
            {
                if (File.Exists(file))
                    File.Delete(file);
                System.Data.Entity.Database.SetInitializer<dbDataContext>(new DropCreateDatabaseIfModelChanges<dbDataContext>());
                new ImportarFeriadosDoGoogleForm().ShowDialog();
                string sql = dbDataContext.CreateDatabaseScript();
                Console.WriteLine(
                       "SQL: \n\t {0}",
                       sql);

            }
        }
    }
}